import torch
from torch.utils.data import Dataset
import pandas as pd
import numpy as np

class FiberDataset(Dataset):
    def __init__(self, csv_file):
        self.data = pd.read_csv(csv_file)

    def __len__(self):
        return len(self.data)

    def __getitem__(self, idx):
        row = self.data.iloc[idx]
        time_seq = np.array([float(x) for x in row['time_seq'].split()], dtype=np.float32)
        freq_seq = np.array([float(x) for x in row['freq_seq'].split()], dtype=np.float32)
        space_feat = np.array([float(x) for x in row['space_feat'].split()], dtype=np.float32)
        label = int(row['label'])
        return torch.tensor(time_seq), torch.tensor(space_feat), torch.tensor(freq_seq), torch.tensor(label)
